package com.ruoyi.web.controller.ydz;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.ExaminationHospital;
import com.ruoyi.web.service.IExaminationHospitalService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 体检医院Controller
 * 
 * @author drx
 * @date 2025-05-19
 */
@Controller
@RequestMapping("/ydz/examinationHospital")
@Api(tags = "体检医院")
public class ExaminationHospitalController extends BaseController
{
    private String prefix = "ydz/examinationHospital";

    @Autowired
    private IExaminationHospitalService examinationHospitalService;

    @RequiresPermissions("ydz:examinationHospital:view")
    @GetMapping()
    public String hospital()
    {
        return prefix + "/examinationHospital";
    }

    /**
     * 查询体检医院列表
     */
    @RequiresPermissions("ydz:examinationHospital:list")
    @PostMapping("/list")
    @ResponseBody
    @ApiOperation("查询体检医院列表")
    public TableDataInfo list(ExaminationHospital examinationHospital)
    {
        startPage();
        List<ExaminationHospital> list = examinationHospitalService.selectExaminationHospitalList(examinationHospital);
        return getDataTable(list);
    }

    /**
     * 导出体检医院列表
     */
    @RequiresPermissions("ydz:examinationHospital:export")
    @Log(title = "体检医院", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    @ApiOperation("导出体检医院列表")
    public AjaxResult export(ExaminationHospital examinationHospital)
    {
        List<ExaminationHospital> list = examinationHospitalService.selectExaminationHospitalList(examinationHospital);
        ExcelUtil<ExaminationHospital> util = new ExcelUtil<ExaminationHospital>(ExaminationHospital.class);
        return util.exportExcel(list, "体检医院数据");
    }

    /**
     * 新增体检医院
     */
    @GetMapping("/add")
    @ApiOperation("新增体检医院")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存体检医院
     */
    @ApiOperation("新增保存体检医院")
    @RequiresPermissions("ydz:examinationHospital:add")
    @Log(title = "体检医院", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ExaminationHospital examinationHospital)
    {
        return toAjax(examinationHospitalService.insertExaminationHospital(examinationHospital));
    }

    /**
     * 修改体检医院
     */
    @ApiOperation("修改体检医院")
    @RequiresPermissions("ydz:examinationHospital:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ExaminationHospital examinationHospital = examinationHospitalService.selectExaminationHospitalById(id);
        mmap.put("examinationHospital", examinationHospital);
        return prefix + "/edit";
    }

    /**
     * 修改保存体检医院
     */
    @ApiOperation("修改保存体检医院")
    @RequiresPermissions("ydz:examinationHospital:edit")
    @Log(title = "体检医院", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ExaminationHospital examinationHospital)
    {
        return toAjax(examinationHospitalService.updateExaminationHospital(examinationHospital));
    }

    /**
     * 删除体检医院
     */
    @ApiOperation("删除体检医院")
    @RequiresPermissions("ydz:examinationHospital:remove")
    @Log(title = "体检医院", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(examinationHospitalService.deleteExaminationHospitalByIds(ids));
    }
}
